home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / CMaster Demo v2.0.3 / CMaster XTRN Projects / OpenAll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-12  |  1.8 KB  |  82 lines  |  [TEXT/KAHL]

  1. /*
  2.  *
  3.  *            OpenAll.c:    open all project files
  4.  *            © 1994 Jersey Scientific, All Rights Reserved
  5.  *
  6.  *            Notes:
  7.  *                Ignore failures as we may be trying to open files already open.
  8.  *                Not sure what think returns when you try to open an alreayd open file. 
  9.  *            History:
  10.  *                06/10/94: New External (took about 30 minutes to write and debug)
  11.  */
  12.  
  13. #include <SetUpA4.h>
  14. #include "XTRN.h"
  15.  
  16.     Boolean
  17. main(
  18.     short            type,    // type of call (XTRN_xxxx, see above)
  19.     XtrnPtr            xP,     // xtern structure
  20.     XtItemPtr        iP,        // some fields are for your private use - see above
  21.     short            keys    // modifier keys associated with this event (KEY, MENU, and ZOOM only)
  22.                             // - or the event return code
  23. ) {
  24.     FSSpec            *fsspP, *ofsspP;
  25.     short            count, i;
  26.     Str255            str;
  27.     Boolean            retCode, ret;
  28.     
  29.     RememberA0();
  30.     SetUpA4();
  31.  
  32.     retCode = FALSE;        // default return value
  33.  
  34.     // decide what to do based on the action
  35.     switch(type) {
  36.     case XTRN_INIT:
  37.     case XTRN_QUIT:
  38.     case XTRN_RAW:
  39.     case XTRN_COOKED:
  40.     case XTRN_WIND_OPEN1_SIZE:
  41.     case XTRN_WIND_OPEN2_DATA:
  42.     case XTRN_WIND_CLOSE:
  43.     case XTRN_ZOOM:
  44.         goto ret;                                    
  45.  
  46.     case XTRN_KEY:
  47.     case XTRN_MENU:
  48.         break;                                            // handle below
  49.     }
  50.  
  51.     // now, look at the key modifiers
  52.     switch(keys) {
  53.     case 0:
  54.         // this will ONLY work for THINK 6 or newer, not THINK 5
  55.         ret = (*xP->getFiles)(xP->window, FILES_PROJ_SRC, &ofsspP, &count);
  56.         if(ret == TRUE) {
  57.             fsspP = ofsspP;
  58.             for(i=0; i<count; ++i) {
  59.                 if(CAPSLOCK) {
  60.                     (*xP->debugPrintf)("Open file %#s", (fsspP++)->name);
  61.                 } else {
  62.                     ret = (*xP->AEOpen)(fsspP++);
  63.                     if(ret != TRUE) {
  64.                         ; // alert? Sysbeep?
  65.                     }
  66.                 }
  67.             }
  68.             DisposePtr((Ptr)ofsspP);
  69.         } else {
  70.             (*xP->softBeep)();
  71.         }
  72.         retCode = TRUE;                                    // doesn't do anything
  73.         break;
  74.     default:
  75.         SysBeep(1);
  76.         break;
  77.     }
  78.  
  79.   ret:
  80.     RestoreA4();
  81.     return retCode;
  82. }